package com.yssw.signboard.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.yssw.common.annotation.Anonymous;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yssw.common.annotation.Log;
import com.yssw.common.core.controller.BaseController;
import com.yssw.common.core.domain.AjaxResult;
import com.yssw.common.enums.BusinessType;
import com.yssw.signboard.domain.SignboardTable;
import com.yssw.signboard.service.ISignboardTableService;
import com.yssw.common.utils.poi.ExcelUtil;
import com.yssw.common.core.page.TableDataInfo;

/**
 * 招牌管理Controller
 *
 * @author yssw
 * @date 2023-03-30
 */
@Anonymous
@RestController
@RequestMapping("/signboard/signboard")
public class SignboardTableController extends BaseController {
    @Autowired
    private ISignboardTableService signboardTableService;

    /**
     * 查询招牌管理列表
     */
//    @PreAuthorize("@ss.hasPermi('signboard:signboard:list')")
    @GetMapping("/list")
    public TableDataInfo list(SignboardTable signboardTable) {
        startPage();
        List<SignboardTable> list = signboardTableService.selectSignboardTableList(signboardTable);
        return getDataTable(list);
    }

    /**
     * 导出招牌管理列表
     */
//    @PreAuthorize("@ss.hasPermi('signboard:signboard:export')")
    @Log(title = "招牌管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SignboardTable signboardTable) {
        List<SignboardTable> list = signboardTableService.selectSignboardTableList(signboardTable);
        ExcelUtil<SignboardTable> util = new ExcelUtil<SignboardTable>(SignboardTable.class);
        util.exportExcel(response, list, "招牌管理数据");
    }

    /**
     * 获取招牌管理详细信息
     */
//    @PreAuthorize("@ss.hasPermi('signboard:signboard:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(signboardTableService.selectSignboardTableById(id));
    }

    /**
     * 新增招牌管理
     */
//    @PreAuthorize("@ss.hasPermi('signboard:signboard:add')")
    @Log(title = "招牌管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SignboardTable signboardTable) {
        return toAjax(signboardTableService.insertSignboardTable(signboardTable));
    }

    /**
     * 修改招牌管理
     */
//    @PreAuthorize("@ss.hasPermi('signboard:signboard:edit')")
    @Log(title = "招牌管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SignboardTable signboardTable) {
        return toAjax(signboardTableService.updateSignboardTable(signboardTable));
    }

    /**
     * 删除招牌管理
     */
//    @PreAuthorize("@ss.hasPermi('signboard:signboard:remove')")
    @Log(title = "招牌管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(signboardTableService.deleteSignboardTableByIds(ids));
    }
}
